﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Smartec.Accounts.Camel.AMS.Model.Entities.SiteUser>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    System Users
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeaderContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<h2> System Users</h2>

<% using (Html.BeginForm()) { %>
<fieldset class="fieldset-filter">
<legend> Filter by.. </legend>
<table>
<tr><td>Role Name</td><td><%:Html.Partial("~/Views/Shared/Filters/SystemRoles.ascx", (string)ViewBag.RoleName)%></td></tr>
</table>
</fieldset>
<% } %>

<% RouteValueDictionary   tRVD = new RouteValueDictionary();
   tRVD["RoleName"] = ViewBag.RoleName;
   %>
   <script type="text/javascript">
       var currentUser = '<%=  HttpContext.Current.User.Identity.Name%>';
   </script>
<%:Html.Partial("~/Views/Shared/CreateDeleteLinks.ascx", "SystemUsers")%>

<%: Html.Telerik().Grid<Smartec.Accounts.Camel.AMS.Model.Entities.SiteUser>()
       .Name("Grid")
       .Columns(columns =>
       {
           columns.Bound(o => o.ID).Title("#").ClientTemplate("<#= ++index #>").Width(30).Filterable(false).Sortable(false);
           columns.Bound(o => o.ID).ClientTemplate("<input  type='checkbox'  <#= currentUser != Email ? \"name='delete'\":\"disabled\" #> value=<#=ID#>/>").Title("<input id='selectall' type='checkbox' onclick='SelectAllRecords();'/> All").Width(50).Filterable(false).Sortable(false).Visible(AuthorizationManager.Authorize("SystemUsers", "Delete"));
           columns.Bound(o => o.ID).Format(Html.ActionLink("Edit", "Edit", new { id = "{0}" }).ToString()).Encoded(false).Title("").Width(50).Filterable(false).Sortable(false).Visible(AuthorizationManager.Authorize("SystemUsers", "Edit"));
           columns.Bound(o => o.ID).Format(Html.ActionLink("Reset Password", "ResetPassword", new { id = "{0}" }).ToString()).Encoded(false).Title("").Width(120).Filterable(false).Sortable(false).Visible(AuthorizationManager.Authorize("SystemUsers", "Edit"));
           columns.Bound(o => o.DisplayName_EN).Width(140);
           columns.Bound(o => o.DisplayName_AR).Width(140);
           columns.Bound(o => o.Email).Width(200);
           columns.Bound(o => o.CustodianName).Width(120);
           columns.Bound(o => o.Roles).Width(200);
           columns.Bound(o => o.StartDate).Title("Start Date").ClientTemplate("<#= StartDate == null?'':StartDate.getDate()+'-'+ (StartDate.getMonth()+1)+'-'+StartDate.getFullYear() #>").Width(100);
           columns.Bound(o => o.EndDate).ClientTemplate("<#= EndDate == null?'':EndDate.getDate()+'-'+ (EndDate.getMonth()+1)+'-'+EndDate.getFullYear() #>").Width(100);
           columns.Bound(o => o.IsActive).ClientTemplate("<input type='checkbox' disabled <#= IsActive == false ? \"\":\"checked\" #> />").Width(100);
       })
           .DataBinding(dataBinding => dataBinding.Ajax().Select("_index", "SystemUsers", tRVD))
       .Filterable()
       .Sortable()
       .Scrollable(scrolling => scrolling.Height("100%"))
       .Pageable(paging => paging.PageSize(20))
       .ClientEvents(events => events.OnDataBinding("onGridDataBinding"))
%>

<%:Html.Partial("~/Views/Shared/CreateDeleteLinks.ascx", "SystemUsers")%>

</asp:Content>

